package coms.delegates;

import EJB.EJBLocator;
import coms.dto.Keyword;
import coms.dto.Location;
import coms.ejb.LocationBeanRemote;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LocationDelegate implements IDelegate<Location> {

    private LocationBeanRemote locationBean;
    
    public LocationDelegate() {
        try {
            this.locationBean = EJBLocator.lookupLocationBean();
        } catch (Exception ex) {
            Logger.getLogger(LocationDelegate.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public boolean create(Location location) {
        locationBean.create(location);
        return true;
    }

     @Override
    public boolean delete(Location location) {
        boolean deleted = locationBean.delete(location);
        return deleted;
    }

     @Override
    public boolean update(Location location) {
        locationBean.update(location);
        return true;
    }

    @Override
    public List<Location> search(Location t) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<Location> findAll() throws Exception {
        return locationBean.findAll();
    }
    
    @Override
    public Location getById(int id) throws Exception {
       return locationBean.getById(id);
    }
}
